package com.zhr.emsg.demo.producer;

import com.zhr.scada.emsg.client.EmsgClient;

import java.util.Date;
import java.util.HashMap;

/**
 * @author LIUJUN
 */
public class MsgProducerThread extends Thread {
    private EmsgClient emsgClient;

    public MsgProducerThread() {
        try {
            emsgClient = new EmsgClient();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            try {
                emsgClient.send("TEST_JNI_TOPIC1", new HashMap<String, Object>() {{
                    put("ms", System.currentTimeMillis());
                    put("date", new Date());
                }});
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
